package com.easemob.helpdesk.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.easemob.helpdesk.activity.MainActivity;
import com.reactnativenavigation.NavigationApplication;
import com.reactnativenavigation.layouts.Layout;
import com.reactnativenavigation.layouts.LayoutFactory;
import com.reactnativenavigation.params.ActivityParams;

/**
 * Created by wsj on 2017/11/24.
 */

public class AccountFragment extends Fragment {

    private ActivityParams activityParams;
    private Layout layout;
    private MainActivity attachActivity;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        View view = inflater.inflate(R.layout.fragment_container, null);
//        layouts = (RelativeLayout) view;
        attachActivity = ((MainActivity) getActivity());
        if(attachActivity != null){
            activityParams = attachActivity.getCurActParams(1);
            if (activityParams != null) {
                layout = LayoutFactory.create(attachActivity, activityParams);
                return layout.asView();
            }
        }

        return new LinearLayout(getActivity());


    }



    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
//        activityParams = ((MainActivity) activity).getCurActParams(1);
//        attachActivity = (MainActivity) activity;

    }


    @Override
    public void onDestroy() {
        super.onDestroy();
        if (layout!=null){
            layout.destroy();
        }
    }
}